<?php
include_once 'fun.php';
include_once 'islogin.php';
$_SESSION['isadmin']=isset($_SESSION['isadmin'])?$_SESSION['isadmin']:'';
  if ($_SESSION['isadmin']!=2&&$_SESSION['isadmin']!=-1) {
      header('Refresh:1;url=shop.php');
      die("请以柜台管理员身份登录");
  }
    //var_dump($_FILES);
    $Name = trim($_POST['Name']);
    
    if(empty($Name))
    {
    header('Refresh:0;url=counter.php');
    die("柜名不能为空");
    }
    else
    {
        $con=connect();
        $sql = "select count(*) from counter where Name like '$Name' ";
        $num=query($sql,$con)->fetch_row();
        if($num[0]==0)
        {
        $sql = "insert into counter (Name) values ('{$Name}')";
        query($sql,$con);
        }
        else {
            header('Refresh:0;url=counter.php');
            die("柜名不能相同");
        }
        echo "<script>
        location.href='counter.php';
        </script>";
    
    }
    
    
?>